<template>
    <div class="xgl-edit">
<el-form ref="form" :model="form" label-width="80px" :rules="rules">
  <el-form-item label="学生" prop="studentId" >
     <el-select filterable v-model="form.studentId" placeholder="请选择学生" :disabled="true">
    <el-option
      v-for="item in options1"
      :key="item.value"
      :label="item.name"
      :value="item.id">
    </el-option>
  </el-select>
  </el-form-item>
  <el-form-item label="课程" prop="courseId" >
     <el-select filterable v-model="form.courseId" placeholder="请选择课程" :disabled="true">
    <el-option
      v-for="item in options"
      :key="item.value"
      :label="item.name"
      :value="item.id">
    </el-option>
  </el-select>
  </el-form-item>
  <el-form-item label="日常得分" prop="dailyScore">
    <el-input v-model="form.dailyScore"></el-input>
  </el-form-item>
  <el-form-item label="考试得分" prop="examScore">
    <el-input v-model="form.examScore"></el-input>
  </el-form-item>
  
  <el-form-item label="总分" prop="score">
    <el-input v-model="form.score"></el-input>
  </el-form-item>
</el-form>
    </div>
</template>
<script>
import {xkxgDetail,xkxgEdit,departmentAll,studentAll} from '@/api/xkxg'
export default{
    //获取父传子
    props:["id"],
    data(){
        return{
            form:{
                name:"",
                id:"",
                studentId:""
            },
            rules:{
               studentId: [
                {required: true, message: '请输入系名称', trigger: 'blur'}
            ],
            },
            options:[{

            }],
            options1:[{

            }]
        }
    },
    methods:{
        onSubmit(cb){
            this.$refs["form"].validate(flag=>{
                if(flag){
                    console.log("参数",this.form);
                    xkxgEdit(this.form).then(res =>{
                        cb(res)
                    })
                }
            })
        },
        getDetail(){
            if(this.id){
               xkxgDetail(this.id).then(res=>{
                console.log(res);
                if(res.code==0){
                    this.form=res.data
                }        
            }) 
            }
            
        },
        getList(){
        departmentAll().then(res=>{
          console.log(res);
          if(res.code===0){
            this.options=res.data
          }
        })
        studentAll().then(res=>{
          console.log(res);
          if(res.code===0){
            this.options1=res.data
          }
        })
      }
    },
    mounted(){
        this.getDetail()
        this.getList()   
    }
}
</script>